import com.qf.utils.JedisPoolUtil;
import org.junit.Test;
import redis.clients.jedis.Jedis;

import java.util.List;
import java.util.Map;

public class Demo {
    @Test
    public void TestJedis(){
        Jedis jedis = new Jedis("10.31.162.13",6379);
        jedis.auth("123");
        String set = jedis.set("name", "tom");
        System.out.println(set);
    }

    @Test
    public void TestString(){
        Jedis jedis = JedisPoolUtil.getJedis();
        jedis.select(2);
        String result = jedis.set("name", "tom");
        System.out.println(result);
        String name = jedis.get("name");
        System.out.println("name = " + name);
       JedisPoolUtil.close(jedis);

    }

    @Test
    public void hsetTest(){
        Jedis jedis = JedisPoolUtil.getJedis();
        jedis.hset("person","name","11");
        jedis.hset("person","age","20");
        jedis.hset("person","address","hz");
        Map<String, String> person = jedis.hgetAll("person");
        System.out.println(person);
        JedisPoolUtil.close(jedis);
    }
    @Test
    public void listTest(){
        Jedis jedis = JedisPoolUtil.getJedis();
        Long number = jedis.rpush("number", "1", "2", "3");
        System.out.println(number);
        List<String> result = jedis.lrange("number", 0, -1);
        System.out.println(result);
    }

}
